package org.blog.service.impl;

import org.blog.dao.MessageMapper;
import org.blog.entity.Message;
import org.blog.entity.param.MessageParam;
import org.blog.service.MessageService;
import org.blog.utils.ObjectToMap;
import org.blog.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.PrimitiveIterator;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;
    @Override
    public int deleteByPrimaryKey(Integer messageId) {
        return 0;
    }

    @Override
    public int insert(Message record) {
        return 0;
    }

    @Override
    public int insertSelective(Message record) {
        return 0;
    }

    @Override
    public Message selectByPrimaryKey(Integer messageId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Message record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Message record) {
        return 0;
    }



    @Override
    public List<Message> getMessages(MessageParam param) {
        Map<String, Object> stringObjectMap = null;
        try {
            stringObjectMap = ObjectToMap.convertBeanToMap(param);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        List<Message>  list = messageMapper.getMessages(stringObjectMap);
        return list;
    }

    @Override
    public boolean delete(Integer messageId) {
        int i = messageMapper.deleteByPrimaryKey(messageId);
        if (i > 0) {
            return true;
        }
        return false;
    }


}
